package com.tanhua.server.controller;

import com.tanhua.model.vo.ReceiveSoundVo;
import com.tanhua.server.service.SoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 桃花传音
 */
@RestController
@RequestMapping("/peachblossom")
public class SoundController {

    @Autowired
    private SoundService soundService;
    /**
     * 桃花传音-发布语音
     */
    @PostMapping
    public ResponseEntity save(@RequestBody MultipartFile soundFile) throws IOException {
        soundService.save(soundFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 桃花传音-接收语音
     */
    @GetMapping
    public ResponseEntity getSound(){
        ReceiveSoundVo vo = soundService.getSound();
        return ResponseEntity.ok(vo);
    }
}
